<template>
	<view class="container">
		<view class="card">
			<view class="item flex-row">
				<view class="label">预案类型：</view>
				<view class="input">{{ form.type || '' }}</view>
			</view>
			<view class="item flex-row">
				<view class="label">修订日期：</view>
				<view class="input">{{ form.updatetime || '' }}</view>
			</view>
			<view class="item flex-row">
				<view class="label">关联风险点：</view>
				<view class="input">{{ form.position_ids || '' }}</view>
			</view>
			<view class="item flex-row">
				<view class="label">关联部门：</view>
				<view class="input">{{ form.deptids || '' }}</view>
			</view>
			<view class="item flex-row">
				<view class="label">关联场所：</view>
				<view class="input">{{ form.place || '' }}</view>
			</view>
			<view class="item flex-row">
				<view class="label">考核状态：</view>
				<view class="input">
					<text v-if="[1,3].includes(form.is_attend)" class="status error">{{ form.is_attend == 1 ? '未参加' : '考核未通过' }}</text>
					<text v-else class="status success">{{ form.is_attend == 2 ? '考核通过' : '无需考核' }}</text>
				</view>
			</view>
			<view v-if="form.is_attend == 1" class="item flex-row">
				<view class="label"></view>
				<view class="input"><view @click="toCheck" class="btn">立即考核</view></view>
			</view>
			<view class="item flex-row">
				<view class="label">附件：</view>
				<view class="input" @click="toLook"><text class="status success">{{ form.file_name }}</text>(点击查看)</view>
			</view>
			<view class="item flex-row bg" style="align-items: flex-start;">
				<view class="label">意见：</view>
				<textarea v-model="form.sugg"/>
			</view>
			<view class="item flex-row bg">
				<view class="label">提交人员：</view>
				<view class="input">{{ username || '' }}</view>
			</view>
			<view class="item flex-row bg">
				<view class="label">提交时间：</view>
				<view class="input">{{ date }}</view>
			</view>
		</view>
	</view>
</template>

<script>
import { date } from '@/common/function.js';
export default{
	data(){
		return {
			userid: uni.getStorageSync('userid'),
			username: '',
			date: '',
			form: {}
		}
	},
	onLoad(){
		this.form = uni.getStorageSync('emergency_plan_detail') || {};
		uni.setNavigationBarTitle({
			title: this.form.name
		});
		this.doDate();
		this.getUserDetail();
	},
	onBackPress(){
		uni.removeStorageSync('emergency_plan_detail');
		uni.redirectTo({
			url: 'index'
		});
		return true;
	},
	methods: {
		// 立即考核
		toCheck(){
			uni.navigateTo({
				url: 'exam?id='+this.form.id
			})
		},
		// 查看文件
		toLook(){
			uni.navigateTo({
				url: '../../jump?src='+encodeURIComponent(this.form.file_url)
			})
		},
		// 处理日期
		doDate(){
			let { year, month, day, hours, minutes, seconds } = date();
			this.date = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
		},
		//获取用户信息
		getUserDetail(){
			let _this = this;
			uni.request({
				url: this.$API.getUserDetail,
				method:"POST",
				data:{ userid: this.userid},
				header:this.$API.get_head(),
				success: (res) => {
					_this.username = res.data.data.NAME;
				}
			})
		}
	}
}
</script>

<style scoped>
.container{
	height: 100vh;
	overflow-y: auto;
}
/*卡片*/
.card{
	margin: 20upx 20upx 0;
	border-radius: 16upx;
	padding: 14upx 20upx 8upx;
	border: 2upx solid #F6F6F6;
	box-shadow: 0 0 4upx #eee;
	background-color: #fff;
	position: relative;
}
.card .title{
	margin-bottom: 6upx;
}
.card .title view{
	height: 42upx;
	font-size: 30upx;
}
.card .item{
	font-size: 30upx;
	margin-top: 20upx;
}
.card .item .label{
	width: 200upx;
}
.card .item.bg textarea,
.card .item .input{
	width: calc(100% - 200upx);
}
.card .item.bg textarea,
.card .item.bg .input{
	padding: 8upx 20upx;
	border-radius: 12upx;
	box-sizing: border-box;
	background-color: #F2F2F2;
}
.card .item.bg textarea{
	height: 160upx;
}

.error{
	color: red;
}
.success{
	color: #5F96F2;
}

.btn{
	color: #fff;
	width: 160upx;
	height: 52upx;
	font-size: 26upx;
	line-height: 52upx;
	border-radius: 6upx;
	text-align: center;
	background-color: #33CC00;
}
</style>
